﻿using B.S.Data.MES.API.Applications.CangKu.Command;
using B.S.Domain.CangKu;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.CangKu.CommandHandlers
{
    public class GetAllCangKuCommandHandlers : IRequestHandler<GetAllCangkuCommand, APIRequst<List<CangKuinfo>>>
    {
        private readonly IBaseRepository<CangKuinfo> cangRepository;

        public GetAllCangKuCommandHandlers(IBaseRepository<CangKuinfo> CangRepository)
        {
            cangRepository = CangRepository;
        }

        public Task<APIRequst<List<CangKuinfo>>> Handle(GetAllCangkuCommand request, CancellationToken cancellationToken)
        {
            var list = cangRepository.GetAll();
            return Task.FromResult(new APIRequst<List<CangKuinfo>>
            {
                Code = RequstCode.成功,
                Msg = RequstCode.成功.ToString(),
                Data = list.ToList()
            });
        }
    }
}
